﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Business.Models
{
    public class Diem
    {
        [Key]
        public int IdDiem { get; set; }
        //public int IdHocSinh { get; set; }
        public virtual HocSinh HocSinh { get; set; }
        //public int MonHoc_LopHoc { get; set; }
        public virtual MonHoc_LopHoc MonHoc_LopHoc { get; set; }
        public byte LoaiDiem { get; set; }
        public byte GiaTri { get; set; }
    }
    public class DiemConfiguration : EntityTypeConfiguration<Diem>
    {

        public DiemConfiguration()
            : base()
        {

            HasKey(d => d.IdDiem);
            Property(d => d.IdDiem).
                HasColumnName("IdDiem").
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).
                IsRequired();
            HasRequired(x => x.HocSinh).
            WithMany().
                Map(x => x.MapKey("IdHocSinh"));
            HasRequired(x => x.MonHoc_LopHoc).
            WithMany().
                Map(x => x.MapKey("MonHoc_LopHoc"));

            Property(d => d.LoaiDiem).
                HasColumnName("LoaiDiem").
                IsRequired();
            Property(d => d.GiaTri).
                HasColumnName("GiaTri").
                IsRequired();
            ToTable("Diem", "dbo");
        }

    }
}